package com.etoak.aspect;

import com.etoak.mapper.UserMapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Aspect
public class AopAspect {

    @Pointcut("execution(* com.etoak.service.UserService.updateVisit(..))")
    public void etoak() {

    }

    @Resource
    UserMapper userMapper;

    @Before("etoak()")
    public void updateVisit(JoinPoint joinPoint) {
        Object[] args = joinPoint.getArgs();
        int id = (int)args[0];
        userMapper.updateVisit(id);
    }

}
